<template>
  <div class="container">
    <h1 class="text-c">版本更新内容</h1>
    <ul v-loading="listLoading">
      <li v-for="item in logData" :key="item.uiId" @click="showDialog(item.uiId)">
        <b>{{ item.title }}</b>
        <span>更新时间：{{ item.createdAt }}</span>
      </li>
      <div class="block text-c">
        <!--分页组件 current-page:当前页   -->
        <!--   page-sizes:每页几条数据（选项）   -->
        <!--   page-size:每页几条数据   -->
        <!--   total:总条数   -->
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="listQuery.page"
          :page-sizes="[10, 20, 30, 40]"
          :page-size="listQuery.limit"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total">
        </el-pagination>
      </div>
    </ul>
    <el-dialog class="check" title="更新查看" :visible.sync="dialogCheck">
      <div class="text-center">
        <h3 >{{dialogContent.title}}</h3>
        <span class="text-center">发布时间{{dialogContent.createdAt}}</span>

      </div>
      <p v-html="dialogContent.content"></p>
    </el-dialog>
  </div>
</template>

<script>
  import { getSystemUpdateLogs } from '@/api/company'

  export default {
    data() {
      return {
        listQuery: {
          page: 1,
          limit: 10
        },
        logData: [],
        total: null,
        listLoading: false,
        dialogCheck: false,
        dialogContent: {}
      }
    },
    created() {
      this.initList()
    },
    methods: {
      showDialog(id) {
        this.dialogCheck = true
        for (var i = 0; i < this.logData.length; i++) {
          if (this.logData[i].uiId == id) {
            this.dialogContent = this.logData[i]
            break
          }
        }
      },
      initList() {
        this.listLoading = true
        getSystemUpdateLogs(this.listQuery).then(res => {
          this.listLoading = false
          this.logData = res.data.data.data
          this.total = res.data.data.total
        }).catch(err => {
          console.log(err)
        })
      },
      handleSizeChange(val) { // 切换每页几条数据方法
        this.listQuery.limit = val
        this.initList()
      },
      handleCurrentChange(val) { // 切换当前页
        this.listQuery.page = val
        this.initList()
      }
    }
  }
</script>
<style scoped>
  el-dialog.check {
    font-size: 14px;
    padding: 0;
  }
  .container {
    padding: 32px;
    background-color: rgb(240, 242, 245);
  }

  .text-c {
    text-align: center;
  }

  ul, li {
    margin: 0;
    padding: 0;
  }

  ul {
    width: 70%;
    margin: 0 auto;
    background: #fff;
    overflow: hidden;
  }

  ul li {
    font-size: 16px;
    padding: 10px 20px 10px 30px;
    line-height: 30px;
    list-style: disc;
    list-style-position: inside;
    color: #0761a0;
    overflow: hidden;
  }

  li b {
    color: #333;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    width: 70%;
  }

  li span {
    color: #999;
    font-size: 12px;
    float: right;
  }

  li:hover {
    cursor: pointer;
    background: #e3f3ff;
    color: #5db75d;
  }

  li:hover b {
    color: #06c;
  }

  li:hover span {
    color: #06c;
  }

  .block {
    padding: 20px 0;
  }
</style>
